/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package taikai;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author jeffmartin
 */
public class MatchesData extends AbstractTableModel {

    private String[] columnNames = new String[]{
        "Red", "White", "Winner"
       };

    private ArrayList<TeamOrPlayerForARound> data = new ArrayList<TeamOrPlayerForARound>();
    private final Class<?>[] types = new Class<?>[]{TeamOrPlayer.class, TeamOrPlayer.class, TeamOrPlayer.class};

    @Override
    public int getRowCount() {
        return data.size();
    }

    @Override
    public int getColumnCount() {
        return columnNames.length;
    }

    @Override
    public String getColumnName(int i) {
        return columnNames[i];
    }

    @Override
    public Class<?> getColumnClass(int i) {
        return types[i];
    }



    @Override
    public Object getValueAt(int row, int col) {
        switch(col) {
            case 0: return data.get(row).getRed();
            case 1: return data.get(row).getWhite();
            case 2: return data.get(row).getWinner();
        }
        return null;
    }


    @Override
    public void setValueAt(Object o, int row, int col) {
    }

    public void add(TeamOrPlayerForARound matchSet) {
        data.add(matchSet);
        fireTableRowsInserted(data.size(), data.size());
    }

}
